<template>
  <div></div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useUserStoreWithout } from '/@/store/modules/user';
import { replaceHistoryState } from '../../../utils/sso/utils';

const { notification } = useMessage();
const loading = ref(false);
const userStore = useUserStoreWithout();
const userInfo = userStore.getUserInfo;

replaceHistoryState(window.location.href);

async function handleLogin() {
  try {
    loading.value = true;
    await userStore.jumpToApp(userInfo);
    notification.success({
      message: '登录成功',
      description: `欢迎回来: ${userInfo.userName}`,
      duration: 3,
    });
  } catch (error) {
    return error;
  } finally {
    loading.value = false;
  }
}

handleLogin();
</script>
